package gdkm.wsz.dao;

import gdkm.wsz.pojo.Company_info;
import org.apache.ibatis.annotations.*;
import java.util.List;

public interface Company_infoDAO {

    /**
     * 根据ID查询企业信息
     */
    @Select("SELECT * FROM company_info WHERE id = #{id}")
    Company_info findById(Long id);

    /**
     * 根据用户ID查询企业信息
     */
    @Select("SELECT * FROM company_info WHERE user_id = #{userId}")
    Company_info findByUserId(Long userId);

    /**
     * 根据公司名称查询企业信息
     */
    @Select("SELECT * FROM company_info WHERE company_name LIKE CONCAT('%', #{companyName}, '%')")
    List<Company_info> findByCompanyName(String companyName);

    /**
     * 查询所有企业信息
     */
    @Select("SELECT * FROM company_info")
    List<Company_info> findAll();

    /**
     * 插入企业信息
     */
    @Insert("INSERT INTO company_info(user_id, company_name, industry, scale, nature, introduction, address, website, contact_person, create_time, update_time) VALUES(#{userId}, #{companyName}, #{industry}, #{scale}, #{nature}, #{introduction}, #{address}, #{website}, #{contactPerson}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Company_info companyInfo);

    /**
     * 更新企业信息
     */
    @Update("UPDATE company_info SET user_id = #{userId}, company_name = #{companyName}, industry = #{industry}, scale = #{scale}, nature = #{nature}, introduction = #{introduction}, address = #{address}, website = #{website}, contact_person = #{contactPerson}, update_time = #{updateTime} WHERE id = #{id}")
    int update(Company_info companyInfo);

    /**
     * 根据ID删除企业信息
     */
    @Delete("DELETE FROM company_info WHERE id = #{id}")
    int delete(Long id);
}
